package asteroids.model.expressions;

import exceptions.IllegalOperandException;

/**
 * A subclass of expression (E) that represents the greater than (>) comparison
 * 
 * @version 1.0
 * 
 * @author	Thijs Peirelinck & Wouter Parys
 *
 */
public class GreaterThan extends DoubleComparison {

	public GreaterThan(E e1, E e2) {
		super(e1, e2);
	}

	@Override
	public Boolean getValue() throws IllegalOperandException {
		if(!this.isValidExpression()) { throw new IllegalOperandException(); }
		return ((Double)getLeftOperand().getValue()) > ((Double)getRightOperand().getValue());
	}
	
	@Override
	public String toString() {
		return getLeftOperand().toString() + " > " + getRightOperand().toString();
	}

	@Override
	public E createCopy() {
		return new GreaterThan(getLeftOperand().createCopy(), getRightOperand().createCopy());
	}
	
	
}
